/*
 * ChooseDeliveryPresenter.java
 * business
 *
 * Created by ChenTao on 2017/2/14.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.main.shoppingcart.choosedelivery;

import android.os.Bundle;

import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.data.model.IConfirmOrderModel;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;

import java.util.List;

/**
 * 选择配送方式 Presenter
 * <p>
 * <p>Created by ChenTao(chentao7v@gmail.com) on 2017/2/14 9:39
 */
public class ChooseShippingWayPresenter implements ChooseShippingWayContract.Presenter {

    private ChooseShippingWayContract.View mChooseDeliveryView;

    private IConfirmOrderModel mConfirmOrderModel;

    public ChooseShippingWayPresenter(
            ChooseShippingWayContract.View view, IConfirmOrderModel confirmOrderModel) {
        mChooseDeliveryView = view;
        mConfirmOrderModel = confirmOrderModel;

        mChooseDeliveryView.setPresenter(this);
    }

    @Override
    public void start() {
    }

    @Override
    public void extraBundle(Bundle bundle) {
        String addressId = bundle.getString(Intents.EXTRA_ADDRESS_ID);
//        String recJson = bundle.getString(Intents.EXTRA_REC_JSON);
//        String favourableJson = bundle.getString(Intents.EXTRA_FAVOURABLE_JSON);

        // todo 首页活动商品

        mConfirmOrderModel.getShippingInfo(mChooseDeliveryView.getPagerTag(), addressId,
                new IConfirmOrderModel.OnLoadListItemsListener() {
                    @Override
                    public void onSuccess(List<DisplayListItem> displayListItems) {
                        mChooseDeliveryView.setDisplayListItems(displayListItems);
                    }

                    @Override
                    public void onFailed() {
                    }
                });
    }
}
